/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Confirmation;

import AdminAddProduct.Product;
import DBManager.DBConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author maconcon
 */
public class ConfirmManager {
    public boolean addProduct(Confirm con)
    {
        boolean result = false;

        try{
            //get connection
            DBConnection db = new DBConnection();
            Connection conn = db.getConnection();

            //Construct SQL Query
            PreparedStatement pstmt =
                conn.prepareStatement("INSERT "
                    + "INTO confirm(ccname,ccnum,cvv2,customerid)"
                    + " values(?,?,?,?)");

            //append values for the parameters
            int i=1;
             pstmt.setString(i++, con.getCcname());
        pstmt.setInt(i++, Integer.parseInt(con.getCcnum()));
        pstmt.setInt(i++, con.getCvv2());
        pstmt.setInt(i++,con.getCustomerid());
   
        
           
            //execute SQL statement
            pstmt.executeUpdate();

            result = true;
        }
        catch(SQLException ex){ex.printStackTrace();}

        return result;
    }
      public boolean checkccv(Confirm con)
    {
        boolean result = false;

        try{
            //get connection
            DBConnection db = new DBConnection();
            Connection conn = db.getConnection();

            //Construct SQL Query
            PreparedStatement pstmt =
                conn.prepareStatement("INSERT "
                    + "INTO confirm(ccname,ccnum,cvv2,customerid)"
                    + " values(?,?,?,?)");

            //append values for the parameters
            int i=1;
             pstmt.setString(i++, con.getCcname());
        pstmt.setInt(i++, Integer.parseInt(con.getCcnum()));
        pstmt.setInt(i++, con.getCvv2());
        pstmt.setInt(i++,con.getCustomerid());
   
        
           
            //execute SQL statement
            pstmt.executeUpdate();

            result = true;
        }
        catch(SQLException ex){ex.printStackTrace();}

        return result;
    }
}
